package wxshop.web.admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wxshop.api.admin.exception.OperationFail;
import wxshop.api.admin.model.FormResult;
import wxshop.api.admin.model.GoodsInfo;
import wxshop.service.admin.impl.GoodsManageServiceImpl;

/**
 * Created by 121874694@qq.com on 2018/3/2.
 */
@SuppressWarnings("SpringJavaAutowiringInspection")
@RestController
@RequestMapping("")
public class GoodsinfoController {
	@Autowired
	private GoodsManageServiceImpl goodsManageService;
	@RequestMapping(value = "/insert",method = RequestMethod.POST)
	public FormResult inser(@RequestBody GoodsInfo goodsInfo){
		return new FormResult(true,goodsManageService.insertGoodsInfo(goodsInfo));
	}
	@RequestMapping(value = "/select",method = RequestMethod.GET)
	public FormResult select(){
		return new FormResult(true,goodsManageService.selectGoodsInfo());
	}
	@RequestMapping("/update")
	public FormResult update(@RequestBody GoodsInfo goodsInfo){
		return new FormResult(true,goodsManageService.updateGoodsInfo(goodsInfo));
	}
	@RequestMapping("/delete")
	public FormResult delete( @RequestBody GoodsInfo goodsInfo){
		return new FormResult(true,goodsManageService.deleteGoodsinforderByid(goodsInfo));
	}
	@ExceptionHandler
	public Object onException(OperationFail e){
		return new FormResult( false,e.getMessage());
	}
}
